<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>操作当当购物车页面</title>
    <link type="text/css" rel="stylesheet" href="../jsImage/cartStyle.css" />
</head>
<body>

<div class="content">
    <div class="logo">
        <img src="../jsImage/dd_logo.jpg"><span onclick="Close();">关闭</span>
    </div>
    <div class="cartList" id="cartList">
        <ul>
            <li>商品图片</li>
            <li>商品信息</li>
            <li>单价</li>
            <li>数量</li>
            <li>总价</li>
            <li>操作</li>
        </ul>
        <ul>
            <li><img src="../jsImage/dog.jpg"></li>
            <li>我和狗狗活下来了</li>
            <li>¥<input type="text" name="price" value="21.90"></li>
            <li><input type="button" name="minus" value="-" onclick="minus(0);"><input type="text" name="amount" value="1"><input type="button" name="plus" value="+" onclick="plus(0);"></li>
            <li id="price0">¥21.90</li>
            <li><p  onclick="collection();">移入收藏</p><p>删除</p></li>
        </ul>
        <ul>
            <li><img src="../jsImage/mai.jpg"></li>
            <li>灰霾来了怎么办</li>
            <li>¥<input type="text" name="price" value="24.00"></li>
            <li><input type="button" name="minus" value="-" onclick="minus(1);"><input type="text" name="amount" value="1"><input type="button" name="plus" value="+" onclick="plus(1);"></li>
            <li id="price1">¥24.00</li>
            <li><p  onclick="collection();">移入收藏</p><p>删除</p></li>
        </ul>
        <ul>
            <li><img src="../jsImage/dog.jpg"></li>
            <li>十宗罪</li>
            <li>¥<input type="text" name="price" value="79.00"></li>
            <li><input type="button" name="minus" value="-" onclick="minus(1);"><input type="text" name="amount" value="1"><input type="button" name="plus" value="+" onclick="plus(1);"></li>
            <li id="price1">¥79.00</li>
            <li><p  onclick="collection();">移入收藏</p><p>删除</p></li>
        </ul>
        <ol>
            <li id="totalPrice">商品总计：<span id="tt"></span></li>
            <li><span onclick="jiesuan()">结 算</span></li>
        </ol>
    </div>
   <!-- <div id="tt">

    </div>-->
</div>
<script type="text/javascript" src="../jsImage/shopping.js">

</script>
<script>
    function  Close() {
        window.close();
    }

    function collection(){
        var flag=confirm("移入收藏后，将不再购物车显示，是否继续操作?");
        if(flag==true){
            alert("移入收藏成功!");
        }
    }
    function jiesuan() {
        var d=document.getElementById("cartList");
        var  dr2=d.children;
        var total=0;
        var str="";
        for(var i=1;i<dr2.length-1;i++){
            var ul=dr2[i];
            var bookname=ul.children[1].innerHTML;
            var price=ul.children[2].lastElementChild.value;
            var num=ul.children[3].firstElementChild.nextElementSibling.value;
            total=price*num;
            str+=bookname+"￥"+(price*num)
            str+="<br>"
        }
        str+="总价:￥"+total;
        document.getElementById("tt").innerHTML=str;
    }
</script>
</body>
</html>